import axios from 'axios'


const Axios = axios.create({
  timeout: 5000,
})

//封装ajax
function ajax(obj) {
  return new Promise(function (resolve) {
    Axios.request({
      url: obj.url,
      method: obj.method || 'GET',
      baseURL: obj.baseURL,
      headers: obj.headers,
      params: obj.params || {},
      data: obj.data || {}
    }).then(function ({
      data
    }) {
      resolve(data)
    }).catch(function (error) {
      console.log('请求失败---------------------')
      resolve(error)
    })
  })
}
export default ajax